/**
 * Project Name:jiuselu-parent
 * File Name:ConfigController.java
 * Package Name:com.fxp.project.jiuselu.web.business.v1.controller.common
 * Date:2021年11月01日 10:34
 * Copyright (c) 2021, Kai.Wang All Rights Reserved.
 */
package com.fxp.project.jiuselu.web.business.v1.controller.common;

import com.fxp.project.jiuselu.web.base.controller.BaseController;
import com.fxp.project.jiuselu.web.base.request.ReqBase;
import com.fxp.project.jiuselu.web.business.v1.request.sms.ReqMessage;
import com.fxp.project.jiuselu.web.domain.CommonResult;
import com.fxp.project.jiuselu.web.models.config.entity.JslConfig;
import com.fxp.project.jiuselu.web.models.config.service.IJslConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName:ConfigController<br/>
 * Function: 配置的控制类型<br/>
 * Date:2021年11月01日 10:34<br/>
 *
 * @author Kai.Wang
 * @version 1.0.0
 * @see
 * @since JDK 8
 */
@RestController
@RequestMapping("/v1/config")
public class ConfigController extends BaseController {

    @Autowired
    IJslConfigService jslConfigService;

    /**
     * logo: 获取当前平台的Logo<br/>
     *
     * @return
     * @author Kai.Wang
     * @date 2021/11/1 10:35
     */
    @PostMapping("logo")
    @CrossOrigin
    public CommonResult logo(@RequestBody @Validated ReqBase reqBase, BindingResult result) {
        super.checkBindResult(result);
        JslConfig jslConfig = jslConfigService.getById(1);
        if (null != jslConfig) {
            return CommonResult.success(jslConfig.getLogo());
        }
        return CommonResult.failed("请在后台进行配置");
    }

    /**
     * introduction: 公司简介<br/>
     *
     * @param reqBase
     * @param result
     * @return
     * @author Kai.Wang
     * @date 2021/11/1 13:46
     */
    @PostMapping("introduction")
    @CrossOrigin
    public CommonResult introduction(@RequestBody @Validated ReqBase reqBase, BindingResult result) {
        super.checkBindResult(result);
        JslConfig jslConfig = jslConfigService.getById(1);
        if (null != jslConfig) {
            return CommonResult.success(jslConfig.getIntroduction());
        }
        return CommonResult.failed("请在后台进行配置");
    }
}
